package com.cyb.myfriend.exception;

import com.cyb.myfriend.constant.StatusCode;

/**
 * 通用异常类
 *
 * @author cyb
 * @date 2024/08/12 08:37
 **/
public class BusinessException extends RuntimeException {

    /**
     * 状态码
     */
    private final int code;

    /**
     * 信息
     */
    private final String message;


    public BusinessException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public BusinessException(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.message = statusCode.getMessage();
    }

    public BusinessException(StatusCode statusCode, String message) {
        this.code = statusCode.getCode();
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

}

